package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.CommissionService;
import com.yixun.qfbao.api.service.PersonnelService;
import com.yixun.qfbao.apidto.UpdateCRReqDto;
import com.yixun.qfbao.apidto.UpdateCRResDto;
import com.yixun.qfbao.apidto.UpdatePwdReqDto;
import com.yixun.qfbao.apidto.UpdatePwdResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.util.exception.TServerException;
import com.yixun.qfbao.vo.UpdateCRReqVo;
import com.yixun.qfbao.vo.UpdatePwdReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2017/11/28
 * @Author sangtao
 * @Computer Administrator
 */
@Service("updateCRHander")
public class UpdateCRHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(UpdateCRHander.class);
    @Autowired
    CommissionService commissionService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        UpdateCRReqVo req = (UpdateCRReqVo) reqDto;
        UpdateCRReqDto resetPwdReqDto = req.getParams();
        BaseResponseDTO<UpdateCRResDto> res = new BaseResponseDTO<UpdateCRResDto>();
        UpdateCRResDto resDto = new UpdateCRResDto();
        try {
            resDto = commissionService.updateCR(resetPwdReqDto);
        }catch (TServerException e){
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg(e.getMessage());
        }catch (Exception e) {
            logger.error("UpdateCRHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("修改失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
